#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
using namespace std;

int S[100005];

struct node {
	int u, v;
	double w;
	node(int ui, int vi, double wi) {
		u = ui;
		v = vi;
		w = wi;
	}
};

vector<node> E;

int getf(int x) {
	if (S[x] == x) return x;
	return S[x] = getf(S[x]);
}

void merage(int x, int y) {
	int a = getf(x), b = getf(y);
	if (a != b) {
		S[a] = b;
		S[x] = b;
	}
}

bool cmp(node x, node y) {
	return x.w < y.w;
}

int main() {
	double LS;
	cin >> LS;
	int n, ai, bi;
	double wi;
	cin >> n;
	for (int i = 0; i <= n; ++i) {
		S[i] = i;
	}
	while (cin >> ai >> bi >> wi) {
		E.push_back(node(ai, bi, wi));
	}
	sort(E.begin(), E.end(), cmp);
	int index = 1, np = 0;
	double ans = 0;
	while (index <= n - 1) {
		if (np >= E.size()) {
			//printf("Impossible\n")
			break;
		} 
		node now = E[np++];
		if (getf(now.u) == getf(now.v)) continue;
		++index;
		ans += now.w;
		merage(now.u, now.v);
	}

	for (int i = 2; i <= n; ++i) {
		if (getf(i) != getf(1)) {
			printf("Impossible\n");
			return 0;
		}
	}
	if (ans > LS) printf("Impossible\n");
	else printf("Need %.02lf miles of cable\n", ans);
	return 0;
}
